package com.tuozixuan.theadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class TheadPoolDemo {

	public static void main(String[] args) {
//		ExecutorService defaultExecutor = new ThreadPoolExecutor(8, 10,
//                100L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(10), Executors.defaultThreadFactory(),
//                new ThreadPoolExecutor.DiscardPolicy());
//		
//		for (int i= 0; i < 19; i++) {
//			defaultExecutor.execute(() -> {
//				try {
//					System.out.println("1" + Thread.currentThread().getId() + "-" + Thread.currentThread().getName());
//					Thread.sleep(5_000);
//				} catch (InterruptedException e) {
//					// TODO Auto-generated catch block
//					e.printStackTrace();
//				}
//			});
//		}
		
		ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
		scheduledExecutorService.schedule(()->{
			
			System.out.println("1" + Thread.currentThread().getId() + "-" + Thread.currentThread().getName());
		}, 5, TimeUnit.SECONDS);
	}

}
